package net.qhzw.vip.qiyu.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import net.qhzw.vip.qiyu.dto.ContractDto;
import net.qhzw.vip.qiyu.entity.DtsCarRental;
import net.qhzw.vip.qiyu.model.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.Map;

public interface DtsCarRentalService extends IService<DtsCarRental> {

    /***
     * 提交租车申请
     * @param communityId
     * @return
     */
    boolean userSubmitCarRentalApp(Long communityId);


    /***
     * 站点管理员提交租车申请
     * @param form
     * @return
     */
    boolean adminCarRentalApp(AdminCarRentalAppForm form);


    /***
     * 分页查询租车申请列表
     * @param page
     * @return
     */
    Map<String, Object> findByPage(Page<DtsCarRental> page, String keywords);


    /***
     * 结算租车费用明细
     * @param form
     */
    CarRentalCostsVo carRentalCosts(CarRentalCostsForm form);


    /***
     * 申请租车(生成合同)
     * @param form
     * @return
     */
    boolean createContract(CarRentalCostsForm form, HttpServletRequest request);


    /***
     * 用户签名
     * @param id
     * @param sign
     * @return
     */
    boolean usrSignature(Long id, String sign, HttpServletRequest request);


    /***
     * 后台管理员查询租车申请
     * @param page
     * @return
     */
    Map<String, Object> sysFindByPage(Page<DtsCarRental> page, Long shopId, SysCarRentalQuery query);

    /***
     * 后台管理员审核租车申请
     * @param id 当前申请ID
     * @param status 审核状态
     * @param auditOpinion 审核意见
     * @return
     */
    boolean audit(Long id, Byte status, String auditOpinion);

    /***
     * 用户余额
     * @param carRentalId
     * @return
     */
    BigDecimal getUserbalance(Long carRentalId);

    /**
     * 获取合同数据
     *
     * @param id
     * @param repairCodeId
     * @param electricVehBrandId
     * @param guaranteeCompanyId
     * @param contractNo
     * @param userSign
     * @return
     */
    ContractData getContractData(Long id, Long repairCodeId, Long electricVehBrandId, Long guaranteeCompanyId, String contractNo, String userSign, Long communityId);

    /***
     * 获取合同html内容
     * @param contractData
     * @param request
     * @return
     */
    String getContent(ContractData contractData, HttpServletRequest request);


    /***
     *根据当前登录用户获取租车信息
     * @return
     */
    UserCarRental getCarRentalByUser();


    /**
     * 关闭合同
     *
     * @param id
     * @return
     */
    boolean closeContract(Long id);

    /**
     * 分页查询在租明细
     *
     * @param page
     * @param query
     * @return
     */
    Map<String, Object> carRentalDetails(Page<DtsCarRental> page, Long shopId, SysCarRentalQuery query);

    /***
     * 导出台账
     * @param response
     * @param query
     * @return
     */
    void exportLedger(HttpServletResponse response, Long shopId, SysCarRentalQuery query);

    /***
     * 导出合同
     * @param id
     * @param response
     */
    void exportContract(Long id, HttpServletResponse response);

    /***
     * 导出今日租车明细
     * @param response
     */
    void export(HttpServletResponse response, Long shopId, String contractNo, String idCard, String mobile, String realName, Long communityId);

    /**
     * 查询租车量
     *
     * @param shopId
     * @return
     */
    Map<String, Integer> carRentalCount(Long shopId);

    /**
     * 查询租车合同公司
     *
     * @param userId
     * @return
     */
    ContractDto findCarRentalContract(Long userId);

    /**
     * 报停 暂停租车业务
     *
     * @param id
     * @return
     */
    boolean stopRep(Long id);


    /**
     * 恢复租车状态
     *
     * @return
     */
    boolean recovery(Map<String, Long> param, HttpServletRequest request);
}
